package com.hh.generator.core.model;

import cn.hutool.core.date.DateUtil;
import lombok.Data;

import java.util.*;

@Data
public class Config {

    private String module;
    private String springApplicationName;
    private String facadeBasePath;
    private String controllerBasePath;
    private String tablePrefix;
    private List<String> methods;

    private String basePackage;
    private String classAuthor = "default";
    private String date = DateUtil.formatDate(new Date());
    private String superEntityClassName;
    private String converterClassName;
    private String columnEnumClassName;
    private String baseControllerClassName;
    private String commonResponseClassName;

    private String pageUtilsClassName = "com.hh.framework.common.db.PageUtils";
    private String baseQueryRequestClassName = "com.hh.framework.common.web.request.BaseQueryRequest";
    private String beanUtilsClassName = "org.springframework.beans.BeanUtils";
    private String lambdaUpdateWrapperClassName = "com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper";
    private String mybatisParamClassName = "org.apache.ibatis.annotations.Param";
    private String pageClassName = "com.baomidou.mybatisplus.extension.plugins.pagination.Page";
    private String listClassName = "java.util.List";
    private String entityPackage;
    private String infoPackage;
    private String mapperPackage;
    private String servicePackage;
    private String serviceImplPackage;
    private String converterPackage;
    private String facadePackage;
    private String facadeImplPackage;
    private String controllerPackage;
    private String enumPackage;
    private String requestPackage;
    private String responsePackage;


    private Map<String, String> dbColumnTypeMap = new HashMap<>();
    private List<String> entityDefaultFields = Arrays.asList("id", "merchantId", "isDeleted",
            "updateTime", "createTime", "createUser", "updateUser", "remark");

    public void init() {
        dbColumnTypeMap.put("tinyint", "Integer");
        dbColumnTypeMap.put("smallint", "Integer");
        dbColumnTypeMap.put("mediumint", "Integer");
        dbColumnTypeMap.put("int", "Integer");
        dbColumnTypeMap.put("integer", "Integer");
        dbColumnTypeMap.put("bigint", "Long");

        dbColumnTypeMap.put("bit", "Boolean");
        dbColumnTypeMap.put("float", "Float");
        dbColumnTypeMap.put("double", "Double");
        dbColumnTypeMap.put("decimal", "BigDecimal");
        dbColumnTypeMap.put("blob", "Integer");

        dbColumnTypeMap.put("char", "String");
        dbColumnTypeMap.put("varchar", "String");
        dbColumnTypeMap.put("tinytext", "String");
        dbColumnTypeMap.put("text", "String");
        dbColumnTypeMap.put("mediumtext", "String");
        dbColumnTypeMap.put("longtext", "String");
        dbColumnTypeMap.put("json", "String");

        dbColumnTypeMap.put("date", "Date");
        dbColumnTypeMap.put("datetime", "Date");
        dbColumnTypeMap.put("timestamp", "Date");

        superEntityClassName = basePackage + ".framework.common.db.SuperEntity";
        converterClassName = basePackage + ".framework.common.converter.Converter";
        columnEnumClassName = basePackage + ".framework.common.constant.ColumnEnum";
        baseControllerClassName = basePackage + ".framework.common.web.BaseController";
        commonResponseClassName = basePackage + ".framework.common.web.response.CommonResponse";
        entityPackage = basePackage + ".xx.common.entity";
        infoPackage = basePackage + ".xx.api.info";
        mapperPackage = basePackage + ".xx.common.mapper";
        servicePackage = basePackage + ".xx.service";
        serviceImplPackage = basePackage + ".xx.service.impl";
        facadePackage = basePackage + ".xx.api";
        facadeImplPackage = basePackage + ".xx.facade.impl";
        converterPackage = basePackage + ".xx.converter";
        controllerPackage = basePackage + ".platform.controller.xx";
        enumPackage = basePackage + ".xx.api.enums";
        requestPackage = basePackage + ".xx.api.request";
        responsePackage = basePackage + ".xx.api.response";
    }
}
